#include "Checkpoint.h"

Checkpoint::Checkpoint(int order1, int spawnX1, int spawnY1, int leftX1, int upY1, int rightX1, int downY1, CPlayer* player1, bool endOfLevel1, int goToLevel1)
{
	order = order1;
	spawnX = spawnX1;
	spawnY = spawnY1;
	leftX = leftX1;
	upY = upY1;
	rightX = rightX1;
	downY = downY1;
	player=  player1;
	endOfLevel = endOfLevel1;
	goToLevel = goToLevel1;

}

Checkpoint::~Checkpoint(void)
{
}

int Checkpoint::Update(){
	if(player->x >= leftX && player->x <= rightX && player->y >= upY && player->y <= downY){
		
		if(endOfLevel == true){
			return goToLevel;
		}
		if(player->checkpoint < order){

			player->checkpoint = order;
			player->spawnX = spawnX;
			player->spawnY = spawnY;
		}
	
	}

	return -1;

}
